package com.kgc.scd.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.config.JmsListenerContainerFactory;
import org.springframework.jms.config.SimpleJmsListenerContainerFactory;

import javax.jms.ConnectionFactory;

/**
 * @description: SearchHistory配置类-添加两种模式的容器工厂，实现两种模式兼容
 **/
@Configuration
public class SearchHistoryConfig {

    @Bean
    public JmsListenerContainerFactory jmsListenerContainerFactoryP2P(ConnectionFactory connectionFactory){
        SimpleJmsListenerContainerFactory containerFactory = new SimpleJmsListenerContainerFactory();
        containerFactory.setConnectionFactory(connectionFactory);
        containerFactory.setPubSubDomain(false);
        return containerFactory;
    }


    @Bean
    public JmsListenerContainerFactory jmsListenerContainerFactoryP2S(ConnectionFactory connectionFactory){
        SimpleJmsListenerContainerFactory containerFactory = new SimpleJmsListenerContainerFactory();
        containerFactory.setConnectionFactory(connectionFactory);
        containerFactory.setPubSubDomain(true);
        return containerFactory;
    }
    
    
}
